#ifndef _USAGEMEMORY_H_
#define _USAGEMEMORY_H_
#include <stdlib.h>
#include <set>

class MemoryMonitor
{
public:
    MemoryMonitor();
    ~MemoryMonitor();

    /*
     * \brief   Add pointer and size
     *
     * \details The size of pointer must be more then 0
     *
     * \param [in] a_Pointer   An address of pointer
     * \param [in] a_Size      A size of element
     *
     * \return                 true if function was executed successfully
     */

    bool Add(void* a_Pointer, size_t a_Size);

    /*
     * \brief   Find a pointer
     *
     * \details This function searching pairs by pointer
     *
     * \param [in] a_Pointer   An address of pointer

     * \return                 size of element else return 0
     */

    size_t Find(void* a_Pointer);

    /*
     * \brief   Update an information
     *
     * \details This function updating the information about pointer and size
     *
     * \param [in] a_Pointer   An address of pointer
     * \param [in] a_Size      A size of element
     *
     * \return                 true if we found pointer else false
     */

    bool Update(void* a_Pointer, size_t a_Size);

    /*
     * \brief   Delete an information
     *
     * \details This function deleted the information about pointer and size
     *
     * \param [in] a_Pointer   An address of pointer
     * \param [in] a_Size      A size of element
     *
     * \return                 true if we found pointer in set else false
     */

    bool Delete(void* a_Pointer);

    /*
     * \brief   Get information about usage memory
     *
     * \details This function returns information about memory usage
     *
     * \return                 return a size of memory usage else 0
     */

    size_t GetUsedMem() const;

private:

    typedef std::pair<void*, size_t> pair_t; //typedef of pair for set
    typedef std::set<pair_t> setPointers_t;

    size_t m_MemoryUse;
    setPointers_t m_Pointers;
};
#endif //#ifndef _USAGEMEMORY_H_
